Contents | Index | < Browse | Browse >
LETTERfeofULETTER
Checks for end-of-file.
Overview
#include <stdio.h>
r = feof(fp);
int r;
FILE *fp;
Portability
ANSI
Description
"feof" returns a value unequal 0 if the end of the file has been reached.
Returns
The function returns a value unequal zero if the file's pointer points to the
end of the file. Otherwise it returns 0.
See also
clearerr , ferror , perror
Example
#include <stdio.h>
void main(void)
{
FILE *stream;
stream = fopen("DUMMY.File", "r");
fgetc(stream); // Read a character from the file
if (feof(stream)) // Check for end-of-file
printf("The file has reached its end\n");
fclose(stream); // Close file
}